package org.pentaho.actioneditor.client;

import com.google.gwt.user.client.ui.*;
import org.pentaho.actioneditor.client.messages.Messages;
import com.google.gwt.user.client.Command;


public class ActionEditorUI {

  private VerticalPanel root = new VerticalPanel();
  private TabPanel tabs = new TabPanel();
  private TextBox title = new TextBox();
  private TextBox version = new TextBox();
  private ListBox loggingLevel = new ListBox();
  private TextBox author = new TextBox();
  private TextBox resultType = new TextBox();
  private CheckBox visible = new CheckBox(Messages.getUIInstance().actioneditorui_Visible());
  private TextBox icon = new TextBox();
  private TextArea description = new TextArea();
  private TextArea help = new TextArea();
  private MenuBar addInput = new MenuBar();
  public static interface ItemCommand {
    public void execute(String text);
  }  public static interface CommandHelper {
    public Command getCommand(MenuItem item);
  }
  ItemCommand addInputCommand;
  CommandHelper addInputCommandHelper;
  private MenuItem deleteInput = new MenuItem(Messages.getUIInstance().actioneditorui_X(), (Command)null);
  private Tree inputTree = new Tree();
  private TreeItem inputTreeInputs = new TreeItem(Messages.getUIInstance().actioneditorui_Inputs());
  private TreeItem inputTreeResources = new TreeItem(Messages.getUIInstance().actioneditorui_Resources());
  private MenuBar addComponent = new MenuBar();
  private MenuItem moveComponentUp = new MenuItem(Messages.getUIInstance().actioneditorui__0001(), (Command)null);
  private MenuItem moveComponentDown = new MenuItem(Messages.getUIInstance().actioneditorui__0002(), (Command)null);
  ItemCommand addComponentCommand;
  CommandHelper addComponentCommandHelper;
  private MenuItem deleteComponent = new MenuItem(Messages.getUIInstance().actioneditorui_X(), (Command)null);
  private Tree processTree = new Tree();
  private MenuBar addOutput = new MenuBar();
  private MenuBar addOutputMenuBar = new MenuBar(true);
  ItemCommand addOutputCommand;
  CommandHelper addOutputCommandHelper;
  private MenuItem deleteOutput = new MenuItem(Messages.getUIInstance().actioneditorui_X(), (Command)null);
  private Tree outputTree = new Tree();
  private VerticalPanel detailsPanel = new VerticalPanel();
  private TextArea xml = new TextArea();
  private Button saveButton = new Button(Messages.getUIInstance().actioneditorui_Save());


  public void init() {
    VerticalPanel obj0 = new VerticalPanel();
    HorizontalPanel obj1 = new HorizontalPanel();
    VerticalPanel obj2 = new VerticalPanel();
    Label obj3 = new Label(Messages.getUIInstance().actioneditorui_Title());
    obj2.add(obj3);
    obj2.add(title);
    Label obj4 = new Label(Messages.getUIInstance().actioneditorui_Version());
    obj2.add(obj4);
    obj2.add(version);
    Label obj5 = new Label(Messages.getUIInstance().actioneditorui_LoggingLevel());
    obj2.add(obj5);
    loggingLevel.addItem(Messages.getUIInstance().actioneditorui_Trace());
    loggingLevel.addItem(Messages.getUIInstance().actioneditorui_Debug());
    loggingLevel.addItem(Messages.getUIInstance().actioneditorui_Info());
    loggingLevel.addItem(Messages.getUIInstance().actioneditorui_Warn());
    loggingLevel.addItem(Messages.getUIInstance().actioneditorui_Error());
    loggingLevel.addItem(Messages.getUIInstance().actioneditorui_Fatal());
    obj2.add(loggingLevel);
    Label obj6 = new Label(Messages.getUIInstance().actioneditorui_Author());
    obj2.add(obj6);
    obj2.add(author);
    Label obj7 = new Label(Messages.getUIInstance().actioneditorui_ResultType());
    obj2.add(obj7);
    obj2.add(resultType);
    obj2.add(visible);
    obj1.add(obj2);
    VerticalPanel obj8 = new VerticalPanel();
    Label obj9 = new Label(Messages.getUIInstance().actioneditorui_Icon());
    obj8.add(obj9);
    obj8.add(icon);
    obj1.add(obj8);
    obj0.add(obj1);
    VerticalPanel obj10 = new VerticalPanel();
    Label obj11 = new Label(Messages.getUIInstance().actioneditorui_Description());
    obj10.add(obj11);
    description.setCharacterWidth(80);
    description.setVisibleLines(5);
    obj10.add(description);
    Label obj12 = new Label(Messages.getUIInstance().actioneditorui_Help());
    obj10.add(obj12);
    help.setCharacterWidth(80);
    help.setVisibleLines(5);
    obj10.add(help);
    obj0.add(obj10);
    tabs.add(obj0,"General");
    VerticalPanel obj13 = new VerticalPanel();
    HorizontalPanel obj14 = new HorizontalPanel();
    VerticalPanel obj15 = new VerticalPanel();
    DisclosurePanel obj16 = new DisclosurePanel(Messages.getUIInstance().actioneditorui_ProcessInputs(), true);
    VerticalPanel obj17 = new VerticalPanel();
    HorizontalPanel obj18 = new HorizontalPanel();
    obj18.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT);
    MenuItem obj19 = new MenuItem(Messages.getUIInstance().actioneditorui_Add(), (Command)null);
    MenuBar obj20 = new MenuBar(true);
    MenuItem obj21 = new MenuItem(Messages.getUIInstance().actioneditorui_String(), (Command)null);
    obj20.addItem(obj21);
    obj21.setCommand(addInputCommandHelper.getCommand(obj21));
    MenuItem obj22 = new MenuItem(Messages.getUIInstance().actioneditorui_Integer(), (Command)null);
    obj20.addItem(obj22);
    obj22.setCommand(addInputCommandHelper.getCommand(obj22));
    MenuItem obj23 = new MenuItem(Messages.getUIInstance().actioneditorui_Long(), (Command)null);
    obj20.addItem(obj23);
    obj23.setCommand(addInputCommandHelper.getCommand(obj23));
    MenuItem obj24 = new MenuItem(Messages.getUIInstance().actioneditorui_Bigdecimal(), (Command)null);
    obj20.addItem(obj24);
    obj24.setCommand(addInputCommandHelper.getCommand(obj24));
    MenuItem obj25 = new MenuItem(Messages.getUIInstance().actioneditorui_List(), (Command)null);
    obj20.addItem(obj25);
    obj25.setCommand(addInputCommandHelper.getCommand(obj25));
    MenuItem obj26 = new MenuItem(Messages.getUIInstance().actioneditorui_Stringlist(), (Command)null);
    obj20.addItem(obj26);
    obj26.setCommand(addInputCommandHelper.getCommand(obj26));
    MenuItem obj27 = new MenuItem(Messages.getUIInstance().actioneditorui_Resultset(), (Command)null);
    obj20.addItem(obj27);
    obj27.setCommand(addInputCommandHelper.getCommand(obj27));
    MenuItem obj28 = new MenuItem(Messages.getUIInstance().actioneditorui_Propertymap(), (Command)null);
    obj20.addItem(obj28);
    obj28.setCommand(addInputCommandHelper.getCommand(obj28));
    MenuItem obj29 = new MenuItem(Messages.getUIInstance().actioneditorui_Propertymaplist(), (Command)null);
    obj20.addItem(obj29);
    obj29.setCommand(addInputCommandHelper.getCommand(obj29));
    MenuItem obj30 = new MenuItem(Messages.getUIInstance().actioneditorui_Date(), (Command)null);
    obj20.addItem(obj30);
    obj30.setCommand(addInputCommandHelper.getCommand(obj30));
    MenuItem obj31 = new MenuItem(Messages.getUIInstance().actioneditorui_Object(), (Command)null);
    obj20.addItem(obj31);
    obj31.setCommand(addInputCommandHelper.getCommand(obj31));
    MenuItem obj32 = new MenuItem(Messages.getUIInstance().actioneditorui_Content(), (Command)null);
    obj20.addItem(obj32);
    obj32.setCommand(addInputCommandHelper.getCommand(obj32));
    MenuItem obj33 = new MenuItem(Messages.getUIInstance().actioneditorui__0000(), (Command)null);
    obj20.addItem(obj33);
    obj33.setCommand(addInputCommandHelper.getCommand(obj33));
    MenuItem obj34 = new MenuItem(Messages.getUIInstance().actioneditorui_Resource(), (Command)null);
    obj20.addItem(obj34);
    obj34.setCommand(addInputCommandHelper.getCommand(obj34));
    obj19.setSubMenu(obj20);
    addInput.addItem(obj19);
    addInput.addItem(deleteInput);
    obj18.add(addInput);
    obj18.setWidth("100%");
    obj17.add(obj18);
    ScrollPanel obj35 = new ScrollPanel();
    inputTree.addItem(inputTreeInputs);
    inputTree.addItem(inputTreeResources);
    inputTree.setWidth("100%");
    obj35.add(inputTree);
    obj35.setWidth("100%");
    obj35.setHeight("100px");
    obj17.add(obj35);
    obj17.setWidth("100%");
    obj16.add(obj17);
    obj16.setWidth("100%");
    obj15.add(obj16);
    DisclosurePanel obj36 = new DisclosurePanel(Messages.getUIInstance().actioneditorui_Process(), true);
    VerticalPanel obj37 = new VerticalPanel();
    HorizontalPanel obj38 = new HorizontalPanel();
    obj38.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT);
    addComponent.addItem(moveComponentUp);
    addComponent.addItem(moveComponentDown);
    MenuItem obj39 = new MenuItem(Messages.getUIInstance().actioneditorui_Add(), (Command)null);
    MenuBar obj40 = new MenuBar(true);
    MenuItem obj41 = new MenuItem(Messages.getUIInstance().actioneditorui_GetDataFrom(), (Command)null);
    MenuBar obj42 = new MenuBar(true);
    MenuItem obj43 = new MenuItem(Messages.getUIInstance().actioneditorui_Relational(), (Command)null);
    obj42.addItem(obj43);
    obj43.setCommand(addComponentCommandHelper.getCommand(obj43));
    MenuItem obj44 = new MenuItem(Messages.getUIInstance().actioneditorui_Olap(), (Command)null);
    obj42.addItem(obj44);
    obj44.setCommand(addComponentCommandHelper.getCommand(obj44));
    MenuItem obj45 = new MenuItem(Messages.getUIInstance().actioneditorui_Xml(), (Command)null);
    obj42.addItem(obj45);
    obj45.setCommand(addComponentCommandHelper.getCommand(obj45));
    MenuItem obj46 = new MenuItem(Messages.getUIInstance().actioneditorui_Mql(), (Command)null);
    obj42.addItem(obj46);
    obj46.setCommand(addComponentCommandHelper.getCommand(obj46));
    MenuItem obj47 = new MenuItem(Messages.getUIInstance().actioneditorui_Javascript(), (Command)null);
    obj42.addItem(obj47);
    obj47.setCommand(addComponentCommandHelper.getCommand(obj47));
    MenuItem obj48 = new MenuItem(Messages.getUIInstance().actioneditorui_PentahoDataIntegration(), (Command)null);
    obj42.addItem(obj48);
    obj48.setCommand(addComponentCommandHelper.getCommand(obj48));
    obj41.setSubMenu(obj42);
    obj40.addItem(obj41);
    obj41.setCommand(addComponentCommandHelper.getCommand(obj41));
    MenuItem obj49 = new MenuItem(Messages.getUIInstance().actioneditorui_PromptSecureFilter(), (Command)null);
    obj40.addItem(obj49);
    obj49.setCommand(addComponentCommandHelper.getCommand(obj49));
    MenuItem obj50 = new MenuItem(Messages.getUIInstance().actioneditorui_Report(), (Command)null);
    MenuBar obj51 = new MenuBar(true);
    MenuItem obj52 = new MenuItem(Messages.getUIInstance().actioneditorui_PentahoReport(), (Command)null);
    obj51.addItem(obj52);
    obj52.setCommand(addComponentCommandHelper.getCommand(obj52));
    MenuItem obj53 = new MenuItem(Messages.getUIInstance().actioneditorui_PentahoAnalysisViewer(), (Command)null);
    obj51.addItem(obj53);
    obj53.setCommand(addComponentCommandHelper.getCommand(obj53));
    obj50.setSubMenu(obj51);
    obj40.addItem(obj50);
    obj50.setCommand(addComponentCommandHelper.getCommand(obj50));
    obj39.setSubMenu(obj40);
    addComponent.addItem(obj39);
    addComponent.addItem(deleteComponent);
    obj38.add(addComponent);
    obj38.setWidth("100%");
    obj37.add(obj38);
    processTree.setWidth("100%");
    processTree.setHeight("100px");
    obj37.add(processTree);
    obj37.setWidth("100%");
    obj36.add(obj37);
    obj36.setWidth("100%");
    obj15.add(obj36);
    DisclosurePanel obj54 = new DisclosurePanel(Messages.getUIInstance().actioneditorui_ProcessOutputs(), true);
    VerticalPanel obj55 = new VerticalPanel();
    HorizontalPanel obj56 = new HorizontalPanel();
    obj56.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT);
    MenuItem obj57 = new MenuItem(Messages.getUIInstance().actioneditorui_Add(), (Command)null);
    MenuItem obj58 = new MenuItem(Messages.getUIInstance().actioneditorui_Dummy(), (Command)null);
    addOutputMenuBar.addItem(obj58);
    obj58.setCommand(addOutputCommandHelper.getCommand(obj58));
    obj57.setSubMenu(addOutputMenuBar);
    addOutput.addItem(obj57);
    addOutput.addItem(deleteOutput);
    obj56.add(addOutput);
    obj56.setWidth("100%");
    obj55.add(obj56);
    TreeItem obj59 = new TreeItem(Messages.getUIInstance().actioneditorui_Outputs());
    outputTree.addItem(obj59);
    outputTree.setWidth("100%");
    outputTree.setHeight("100px");
    obj55.add(outputTree);
    obj55.setWidth("100%");
    obj54.add(obj55);
    obj54.setWidth("100%");
    obj15.add(obj54);
    obj15.setWidth("200px");
    obj14.add(obj15);
    detailsPanel.setWidth("500px");
    obj14.add(detailsPanel);
    obj14.setWidth("100%");
    obj13.add(obj14);
    obj13.setWidth("100%");
    tabs.add(obj13,"Process");
    VerticalPanel obj60 = new VerticalPanel();
    xml.setCharacterWidth(80);
    xml.setVisibleLines(28);
    obj60.add(xml);
    tabs.add(obj60,"XML Source");
    tabs.selectTab(0);
    tabs.setWidth("100%");
    root.add(tabs);
    DockPanel obj61 = new DockPanel();
    obj61.add(saveButton, DockPanel.EAST);
    root.add(obj61);
    root.setWidth("100%");

  }

  public VerticalPanel getRoot() {
    return root;
  }
  public TabPanel getTabs() {
    return tabs;
  }
  public TextBox getTitle() {
    return title;
  }
  public TextBox getVersion() {
    return version;
  }
  public ListBox getLoggingLevel() {
    return loggingLevel;
  }
  public TextBox getAuthor() {
    return author;
  }
  public TextBox getResultType() {
    return resultType;
  }
  public CheckBox getVisible() {
    return visible;
  }
  public TextBox getIcon() {
    return icon;
  }
  public TextArea getDescription() {
    return description;
  }
  public TextArea getHelp() {
    return help;
  }
  public MenuBar getAddInput() {
    return addInput;
  }
  public void setAddInputCommand(ItemCommand itemCommand) {
    this.addInputCommand = itemCommand;
    addInputCommandHelper = new CommandHelper() {
      public Command getCommand(final MenuItem item) {
        Command cmd = new Command() {
          public void execute() {
            addInputCommand.execute(item.getText());
          }
        };
        return cmd;
      }
    };
  }
  public MenuItem getDeleteInput() {
    return deleteInput;
  }
  public Tree getInputTree() {
    return inputTree;
  }
  public TreeItem getInputTreeInputs() {
    return inputTreeInputs;
  }
  public TreeItem getInputTreeResources() {
    return inputTreeResources;
  }
  public MenuBar getAddComponent() {
    return addComponent;
  }
  public MenuItem getMoveComponentUp() {
    return moveComponentUp;
  }
  public MenuItem getMoveComponentDown() {
    return moveComponentDown;
  }
  public void setAddComponentCommand(ItemCommand itemCommand) {
    this.addComponentCommand = itemCommand;
    addComponentCommandHelper = new CommandHelper() {
      public Command getCommand(final MenuItem item) {
        Command cmd = new Command() {
          public void execute() {
            addComponentCommand.execute(item.getText());
          }
        };
        return cmd;
      }
    };
  }
  public MenuItem getDeleteComponent() {
    return deleteComponent;
  }
  public Tree getProcessTree() {
    return processTree;
  }
  public MenuBar getAddOutput() {
    return addOutput;
  }
  public MenuBar getAddOutputMenuBar() {
    return addOutputMenuBar;
  }
  public void setAddOutputCommand(ItemCommand itemCommand) {
    this.addOutputCommand = itemCommand;
    addOutputCommandHelper = new CommandHelper() {
      public Command getCommand(final MenuItem item) {
        Command cmd = new Command() {
          public void execute() {
            addOutputCommand.execute(item.getText());
          }
        };
        return cmd;
      }
    };
  }
  public MenuItem getDeleteOutput() {
    return deleteOutput;
  }
  public Tree getOutputTree() {
    return outputTree;
  }
  public VerticalPanel getDetailsPanel() {
    return detailsPanel;
  }
  public TextArea getXml() {
    return xml;
  }
  public Button getSaveButton() {
    return saveButton;
  }

}
